package com.qpf.mycms.component.auth.service;

import com.qpf.mycms.api.PasswordServiceApi;
import org.springframework.context.annotation.Lazy;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

@Service
public class PasswordServiceImpl implements PasswordServiceApi {
    // 将BCryptPasswordEncoder提取从WebSecurityConfiguration提取到单独的一个配置类否则会导致循环依赖,或者在此使用@Lazy注解
//    @Lazy
    @Resource
    private BCryptPasswordEncoder passwordEncoder;
    @Override
    public String encode(String password) {
        return passwordEncoder.encode(password);
    }
}
